import ecsSystem from '../app/ecs/ecsSystem';
import velocityComponent from '../ecs-component/velocityComponent';
import positionComponent from '../ecs-component/positionComponent';
export default class moveSystem extends ecsSystem {
    constructor() {
        // 此处super传入sort值, 它影响system的执行顺序, 值越小优先级越高
        super(100);
    }

    ecsUpdate(dt: number) {
        this.ecs.getEntitys([velocityComponent, positionComponent]).forEach(function (entity) {
            const velocity = entity.getComponent(velocityComponent);
            const position = entity.getComponent(positionComponent);

            position.x += velocity.x * dt;
        })
    }
}